package com.demonzym.http.api;

import com.demonzym.activity.data.PlaylistInfoData;
import com.demonzym.framework.net.http.HttpRequest;
import com.demonzym.framework.net.http.HttpResponse;
import com.demonzym.framework.net.task.AbstractHttpTask;

public class GetPlaylistInfoTask extends AbstractHttpTask {
	
	private String playlistCodes, count;
	
	public GetPlaylistInfoTask(String listcode, String count){
		playlistCodes = listcode;
		this.count = count;
	}
	public GetPlaylistInfoTask(String listcode){
		playlistCodes = listcode;
		this.count = "10";
	}
	
	@Override
	public HttpRequest buildHttpRequest() {
		HttpRequest hr = new HttpRequest(ConstUrl.TUDOU_API_HOST);
		hr.addHttpParams("method", "playlist.info.get");
		hr.addHttpParams("appKey", ConstUrl.TUDOU_APPKEY);
		hr.addHttpParams("format", "json");
		hr.addHttpParams("playlistCodes", playlistCodes);
		hr.addHttpParams("ceiling", count);
		return hr;
	}

	@Override
	protected PlaylistInfoData[] buildResponseObject(HttpResponse hr) {
		return PlaylistInfoData.parsePlaylist(new String(hr.data));
	}

	@Override
	protected int buildType() {
		return Api.GETPLAYLIST;
	}
}
